package com.ruoyi.train.controller;


import java.util.List;
import javax.servlet.http.HttpServletResponse;


import com.ruoyi.train.domain.Vo.ExamApplicationVo;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import com.ruoyi.train.domain.ExamApplication;
import com.ruoyi.train.service.IExamApplicationService;

/**
 * 提交考试申请Controller
 * 
 * @author wusihao
 * @date 2023-03-26
 */
@CrossOrigin
@Api(tags = "考试申请表", value = "考试申请表接口")
@RestController
@RequestMapping("/exam/application")
public class ExamApplicationController extends BaseController
{
    @Autowired
    private IExamApplicationService examApplicationService;

    /**
     * 查询提交考试申请列表
     */
    @ApiOperation("查询考试申请表列表")
    @GetMapping("/list")
    public TableDataInfo list(ExamApplicationVo examApplicationVo)
    {
        startPage();
        List<ExamApplicationVo> list = examApplicationService.selectExamApplicationVoList(examApplicationVo);
        return getDataTable(list);
    }

    /**
     * 导出提交考试申请列表
     */
    @ApiOperation("导出考试申请表")
    @Log(title = "提交考试申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamApplication examApplication)
    {
        List<ExamApplication> list = examApplicationService.selectExamApplicationList(examApplication);
        ExcelUtil<ExamApplication> util = new ExcelUtil<ExamApplication>(ExamApplication.class);
        util.exportExcel(response, list, "提交考试申请数据");
    }

    /**
     * 获取提交考试申请详细信息
     */
    @ApiOperation("查看考试申请表详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) throws Exception {
        ExamApplicationVo data = examApplicationService.selectExamApplicationVoById(id);
        return success(data);
    }

    /**
     * 新增提交考试申请
     */
    @ApiOperation("新增考试申请表")
    @Log(title = "提交考试申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamApplication examApplication)
    {
        return toAjax(examApplicationService.insertExamApplication(examApplication));
    }

    /**
     * 提交考试申请：输入考试申请表信息
     */
    @ApiOperation("修改考试申请表")
    @Log(title = "提交考试申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamApplication examApplication)
    {
        return toAjax(examApplicationService.uploadExamApplication(examApplication));
    }

    /**
     * 删除提交考试申请
     */
    @ApiOperation("删除考试申请表")
    @Log(title = "提交考试申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(examApplicationService.deleteExamApplicationByIds(ids));
    }

    /**
     * 提交考试申请1
     */
    @ApiOperation("提交考试申请1")
    @Log(title = "学员信息", businessType = BusinessType.DELETE)
    @GetMapping("/sumbitExamOne/{examApplicationId}")
    public AjaxResult submitExamApplication1(@PathVariable Long examApplicationId)
    {
        return toAjax(examApplicationService.submitExamApplication1(examApplicationId));
    }
}
